package com.asl.website.item.domain;

/**
 * @author 482944566@qq.com
 * @version 1.0
 * @date 2025-05-21
 */

import com.asl.common.utils.StringUtils;
import com.asl.website.common.Language;

/**
 * 客户服务项响应DTO
 */
public class TransportServiceItemDTO {
    private Long id;
    private Long typeCode;
    private String itemIcon;
    private String title;
    private String description;
    private Integer sortOrder;
    private String language;

    public TransportServiceItemDTO(TTransportServiceItem item, String language) {
        this.id = item.getId();
        this.typeCode = item.getTypeCode();
        this.itemIcon = item.getItemIcon();
        this.sortOrder = item.getSortOrder();
        this.language = language;

        switch (Language.fromCode(language)) {
            case EN_US:
                this.title = StringUtils.firstNonBlank(item.getItemTitleEn(), item.getItemTitleZh());
                this.description = StringUtils.firstNonBlank(item.getItemDescEn(), item.getItemDescZh());
                break;
            case DE_DE:
                this.title = StringUtils.firstNonBlank(item.getItemTitleDe(), item.getItemTitleZh());
                this.description = StringUtils.firstNonBlank(item.getItemDescDe(), item.getItemDescZh());
                break;
            default: // 默认中文
                this.title = item.getItemTitleZh();
                this.description = item.getItemDescZh();
        }
    }

    // getters
    public Long getId() {
        return id;
    }

    public Long getTypeCode() {
        return typeCode;
    }

    public String getItemIcon() {
        return itemIcon;
    }

    public String getTitle() {
        return title;
    }

    public String getDescription() {
        return description;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    public String getLanguage() {
        return language;
    }
}